#include "thread.h"
#include "itrupt_timer.h"
#include "schedule.h"

void init_timer()
{
    struct itimerval itimer;

    int ret = 0;

    ret = getitimer(ITIMER_REAL, &itimer);  //init itimer

    if (ret)
    {
        printf("gettimer wrong\n");
    }

    itimer.it_interval.tv_sec = 1;
    itimer.it_interval.tv_usec = 0;

    itimer.it_value.tv_sec = 1;
    itimer.it_value.tv_usec = 0;

    ret = setitimer(ITIMER_REAL, &itimer, NULL);    //set timer,expried signal alarm
    if (ret)
    {
        printf("set timer wrong\n");
    }

    return;


}

void tick_handler(int sig)
{
    
	//printf("%s entry\n", __func__);
	/*
    timer_func();时钟中断处
    */

    timer_schedule();
}
